<?php
/**
 * Created by PhpStorm.
 * User: function
 * Date: 2018-05-03
 * Time: 23:19
 */

namespace app\common\logic;

use app\common\logic\Logic;
use app\common\model\Goods;
use app\common\model\Type;

class SearchLogic extends Logic
{
    /**
     * @param $word 关键词
     * @param $user_id 用户信息
     * @param $sellerId 店铺的user_id，不是id字段
     */
    public function searchMall($word, $userId, $sellerId)
    {
        
        $field = 'id,title,thumb,price,sales,comments,type_title,keyword';
        
        //名称、类目、关键词
        //区分店铺
        $query = Goods::where('status', 3);
        if ($sellerId) {
            $query = $query->where('user_id', $sellerId);
        }
        $lists = $query->where('title|keyword|type_title', 'like', '%' . $word . '%')->field($field)->paginate();
        

        
        return $lists;
    }
    
    
}